package com.aicheyoudao;

import java.util.ArrayList;

import com.baidu.mapapi.search.core.PoiInfo;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class SearchHintAdapter extends BaseAdapter {

	private LayoutInflater mInflater;
	private ArrayList<PoiInfo> hintData;

	public SearchHintAdapter(Context context, ArrayList<PoiInfo> hintData) {
		mInflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		this.hintData = hintData;
	}

	@Override
	public int getCount() {
		return hintData.size();
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		return createViewFromResource(position, convertView, parent,
				android.R.layout.simple_list_item_1);
	}

	private View createViewFromResource(int position, View convertView,
			ViewGroup parent, int resource) {
		TextView tv;
		if (convertView == null) {
			tv = (TextView) mInflater.inflate(resource, parent, false);
		} else {
			tv = (TextView) convertView;
		}

		tv.setText(hintData.get(position).name);
		return tv;
	}

}
